<?php
declare (strict_types = 1);

namespace app\middleware;

class Check
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        /*
         * 判断访问api的来源
         */
//        $header = $request->header();
//        if (!isset($header['referer'])){
//            return json(['code'=>451,'msg'=>'非法请求']);
//        }
//        // 指定域名访问
//        if ($header['referer'] != 'http://192.168.1.1'){
//            return json(['code'=>451,'msg'=>'非法请求']);
//        }

        return $next($request);
    }
}
